package com.itheima.demo;

import com.itheima.domain.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        InputStream is = Resources.getResourceAsStream("sql.xml");
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);
        SqlSession session = factory.openSession();
        /*User u = session.selectOne("com.itheima.mapper.UserMapper.findById", 27);

        System.out.println(u);

         */
        List<User> list = session.selectList("com.itheima.mapper.UserMapper.findAll");
        System.out.println(list);
        session.commit();
        is.close();
        session.close();
    }
}
